There are two ways to create entities in the NHibernate Designer: model-first and database-first.

Creating Entities Model-First

To create an entity, open the Toolbox and drag the Entity icon onto the design surface. You can now configure the entity using the Properties window. To add identity properties and entity properties, right-click the relevant compartment and choose Add New Identity Property or Add New Entity Property. Again, once you have added a property you can configure it using the Properties window, for example to set its data type or to customise its mapping behaviour.

Creating Entities Database-First

If you already have a database which defines the entities you want to use, you can drag tables from that database onto the design surface. Open the Server Explorer, expand your desired database’s Tables folder, and drag on the table or tables that you want to create entities for.

Entity Configuration

The main piece of configuration that is required on entities is identity generation. For each identity property, you must specify how NHibernate should generate values for that property. Select the property, go to the Properties window and set the Identity Generator option. Depending on the method you choose, you may need to configure additional settings—for example, the HiLo method requires you to specify the hi-lo table name and column.

You can specify a default identity generator at the model level by clicking on the model background and setting the Default Identity Generator option. Again, you may need to configure additional settings. This default generator will be used for all identity properties where you don’t configure a specific generator.